package com.pony.controller.user;


import com.pony.dto.PageDTO;
import com.pony.dto.TypeDTO;
import com.pony.enums.AppHttpCodeEnum;
import com.pony.result.R;
import com.pony.service.ITypeService;
import com.pony.utils.StringUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author pony
 * @since 2023-11-16
 */
@Slf4j
@RestController("userTypeController")
@RequestMapping("/user/type")
@CrossOrigin(origins = "*")
public class TypeController {
    @Autowired
    private ITypeService typeService;

    /**
     * 获取分类分页信息，包含分类下的所有酒水信息
     * @param pageDTO
     * @return
     */
    @PostMapping("/page")
    public R getPage(@RequestBody PageDTO pageDTO){
        log.info("分页信息"+pageDTO.toString());
        return typeService.getPageAll(pageDTO);
    }

    /**
     * 根据分类id，查询单个分类信息以及其酒水信息
     * @param id
     * @return
     */
    @PostMapping("/{id}")
    public R selectOneById(@PathVariable("id") Integer id, @RequestBody PageDTO pageDTO){
        return typeService.selectById(id, pageDTO);
    }
}
